/* ==============================================================================
 * 创 建 者：lyt
 * 创建日期：2017-07-14	
 * 功能描述：

 * 修 改 人:
 * 修改时间:
 * 修改描述：
 * ==============================================================================*/
//挂卖记录详情
var GetRecordInfoUrl = baseUrl+'EPTradeF/GetSaleRecordInfo';
//挂卖
var ConfirmUrl =  baseUrl+'EPTradeF/Confirm';
//拒绝收款
var NConfirmUrl =  baseUrl+'EPTradeF/NConfirm';
//取消挂卖
var cancleSellUrl =  baseUrl+'EPTradeF/RevokeSale';
//会员信息获取
var getMemberViewUrl = baseUrl + 'MemberF/MemberView';

var vu;
var oid = getURLParameter("oid");

$(function(){
	initVue();
});

function initVue(){
	vu = new Vue({
		el : '#content',
		data : {
			member : '',
			
			order : {
				SaleCount : 0,
				SalePrice : 0,
			},
			Voucher : '',
		},
		mounted: function() {
			this.GetRecordInfo();
		},
		methods : {
			GetRecordInfo : GetRecordInfo,
			Confirm : Confirm,
			NConfirm:NConfirm,
			cancleSell : cancleSell,
			getMemberView : getMemberView,
		}
	})
}

function cancleSell(){
	var btnArray = ['确定', '取消'];
	mui.confirm('确定取消挂卖?', ' ', btnArray, function(e) {
		if(e.index == 0) {
			common.post(cancleSellUrl,{ OID : oid},'json',function(r){
				if(r.ErrorCode==0){
					mui.toast(r.ErrorMsg);
					setTimeout(function(){
						location.href = 'tradeSell.html';
					},1000)
				}else{
					mui.toast(r.ErrorMsg);
				}
			})
		}
	})
}

function Confirm(){
//	if(!vu.Voucher){
//		mui.toast("请上传凭证");
//		return;
//	}
	var btnArray = ['确定', '取消'];
	mui.confirm('确定收款么?', ' ', btnArray, function(e) {
		if(e.index == 0) {
			common.post(ConfirmUrl,{OID : oid},'json',function(r){
				if(r.ErrorCode==0){
					mui.toast(r.ErrorMsg);
					setTimeout(function(){
						location.reload();
					},1000)
				}else{
					mui.toast(r.ErrorMsg);
				}
			})
		}
	})
}

function NConfirm(){
	var btnArray = ['确定', '取消'];
	mui.confirm('确定拒绝收款?', ' ', btnArray, function(e) {
		if(e.index == 0) {
			common.post(NConfirmUrl,{OID : oid},'json',function(r){
				if(r.ErrorCode==0){
					mui.toast(r.ErrorMsg);
					setTimeout(function(){
						location.reload();
					},1000)
				}else{
					mui.toast(r.ErrorMsg);
				}
			})
		}
	})
}


function GetRecordInfo(){
	common.get(GetRecordInfoUrl,{OID : oid},'json',function(r){
		if(r.ErrorCode==0){
			vu.order = r.Data.Record;
		}else{
			mui.toast(r.ErrorMsg);
		}
	})
}

function getMemberView(){
	common.get(getMemberViewUrl,{},'json',function(r){
		if(r.ErrorCode==0){
			vu.member = r.Data.member;
		}else{
			mui.toast(r.ErrorMsg);
		}
	})
}
